package com.company.笔试.tx;

/**
 * 静态代理
 */
public class ProxyTest {
    public static void main(String[] args) {
        System.out.println("--------------静态代理----------------");
        //静态代理
        StaticProxy proxy = new StaticProxy();
        proxy.display();
    }
}


//抽象主题
interface  Subject{
    String display();
}


//真实主题
class RealSubject implements Subject{

    @Override
    public String display() {
        System.out.println("访问真实主题...气泡科技核心处理");
        return "RealSubject";
    }
}


//静态代理
class StaticProxy implements Subject{


    //代理持有 对象
    private RealSubject realSubject = new RealSubject();

    @Override
    public String display() {
        System.out.println("代理: 前置增强! 包装!");
        String res  = realSubject.display();
        System.out.println("代理: 后置增强! 加价!");
        return res;
    }
}







